package com.gugee.ins.web.controller.view;

import com.gugee.ins.web.dto.InsBloggerSearchData;
import com.gugee.ins.web.service.DicService;
import com.gugee.ins.web.service.InsBloggerService;
import com.gugee.ins.web.service.TempBloggerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
public class InsInfluencerController extends InsWebBaseController {

    @Autowired
    TempBloggerService tempBloggerService;

    @Autowired
    DicService dicService;

    @Autowired
    InsBloggerService insBloggerService;

    @RequestMapping("/influencer/{username}")
    public ModelAndView influencer(@PathVariable String username){
        ModelAndView modelAndView = getModel(20);
        // JdbcTemplateHelper.setDataSource(insDataSource);
        modelAndView.setViewName("ins/influencer/index");
        modelAndView.addObject("blogger",tempBloggerService.getByUsername(username));
        return modelAndView;
    }

    @RequestMapping(value = "/search",method = RequestMethod.GET)
    public ModelAndView search(){
        ModelAndView modelAndView = getModel(15);
        InsBloggerSearchData searchData = new InsBloggerSearchData();
        modelAndView.addObject("listData",insBloggerService.getPageByEs(searchData));
        modelAndView.addObject("nations",dicService.getNations(1));
        modelAndView.addObject("languages",dicService.getLanguage(1));
        modelAndView.addObject("category",dicService.getOverallCategory());
        modelAndView.setViewName("ins/search/index");
        return modelAndView;
    }
    @RequestMapping(value = "/most-followers",method = RequestMethod.GET)
    public ModelAndView mostFollower(){
        ModelAndView modelAndView = getModel(16);
        modelAndView.setViewName("ins/follower/most");
        return modelAndView;
    }
    @RequestMapping(value = "/most-likes",method = RequestMethod.GET)
    public ModelAndView mostLike(){
        ModelAndView modelAndView = getModel(17);
        modelAndView.setViewName("ins/like/most");
        return modelAndView;
    }
    @RequestMapping(value = "/account-search",method = RequestMethod.GET)
    public ModelAndView accountSearch(){
        ModelAndView modelAndView = getModel(18);
        modelAndView.setViewName("ins/search/default");
        return modelAndView;
    }
    @RequestMapping(value = "/analytics",method = RequestMethod.GET)
    public ModelAndView analytics(){
        ModelAndView modelAndView = getModel(19);
        modelAndView.setViewName("ins/analytics/index");
        return modelAndView;
    }
}
